/*
 * @Author: steven.wjx
 * @Date:   2020-03-31 18:04:39
 * @Last Modified by:   steven.wjx
 * @Last Modified time: 2020-03-31 18:04:54
 */
;
(function($, window, document, undefined) {
    "use strict";

    function init(target) {
        return $(target);
    }

    function setSize(target, width) {
        var opts = $.data(target, 'demo').options;
        if (width) opts.width = width;
    }

    //定义Demo的构造函数
    $.fn.demo = function(options, param) {
        if (typeof options === 'string') {
            var method = $.fn.demo.methods[options];
            if (method) {
                return method(this, param);
            }
        }
        options = options || {};
        return this.each(function() {
            setSize(this)
        })
    };

    $.fn.demo.VERSION = '1.0.0';

    //定义Demo的方法
    $.fn.demo.methods = {
        options: function(data) {
            return $.data(data[0], 'demo').options;
        }
    }
    //在插件中使用Demo扩展
    $.fn.demo.defaults = {
        width: 'auto'
    };
})(jQuery, window, document);